Skip to content

Validate AtomicFixnum update results before mutation - #1114

Open
OskarEichler wants to merge 2 commits into
ruby-concurrency:masterfrom
OskarEichler:codex/atomic-fixnum-update
Open

Validate AtomicFixnum update results before mutation#1114
OskarEichler wants to merge 2 commits into
ruby-concurrency:masterfrom
OskarEichler:codex/atomic-fixnum-update

Conversation

@OskarEichler

Copy link
Copy Markdown

Validates the block result through the same integer assignment path before changing state. Invalid update results now raise without corrupting the mutex-backed or native atomic value.

Verified by focused native/mutex specs and models; the review composite passes 2,796 examples with no failures.

@bensheldon bensheldon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would it become corrupted? Can it be tested?

@OskarEichler

Copy link
Copy Markdown
Author

The invalid block result replaces the stored integer in the mutex implementation; the C implementation likewise passed the arbitrary Ruby VALUE through compare-and-set without enforcing the numeric invariant. Later numeric operations then operate on a non-integer value. I added a shared regression example that returns a String, verifies the update raises, and verifies the previous integer remains intact. It runs against both MutexAtomicFixnum and CAtomicFixnum; after compiling the extension, the focused suite passes with 59 examples and 0 failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants